<!-- src/App.vue -->
<template>
    <div id="app">
        <nav class="navbar">
            <div class="nav-container">
                <h1 class="nav-title">待办事项管理</h1>
                <div class="nav-buttons">
                    <template v-if="!store.state.user">
                        <button @click="$router.push('/login')" class="btn btn-primary">登录</button>
                        <button @click="$router.push('/register')" class="btn btn-secondary">注册</button>
                    </template>
                    <template v-else>
                        <span class="welcome-text">欢迎你，{{ store.state.user.username }}</span>
                        <button @click="logout" class="btn btn-danger">退出</button>
                    </template>
                </div>
            </div>
        </nav>
        
        <main class="main-content">
            <router-view></router-view>
        </main>
    </div>
</template>

<script setup>
import store from './store/index.js'

const logout = () => {
    store.logout()
    localStorage.removeItem('user')
}
</script>
